/* overallAuth 系统接口
ApprovalFlow系统的权限全部来自于overallAuth系统
*/

import { LoginInput } from '@/model/user/LoginInput';
import Http from '../http';
import SSOAuthCenterHttp from '../ssoAuthCenterHttp';

export const login = function (loginForm: LoginInput) {
  return Http.post('/api/OverallAuthApi/Login', loginForm)
}

//sso统一登录接口
export const ssoLogin = function (loginForm: any) {
    return SSOAuthCenterHttp.post('/api/SSOAuthCenter/Login', loginForm)
}

//检查授权状态
export const checkAuthState = function () {
    return SSOAuthCenterHttp.get('/api/SSOAuthCenter/CheckAuthState')
}


//获取公司下系统的菜单
export const getMenuByUserId = async function () {
  return Http.get('/api/OverallAuthApi/GetMenuByUserId');
}

//获取所有公司-select结构，登录使用
export const getCorporationSelect = async function () {
  return await Http.get('/api/OverallAuthApi/GetCorporation');
}

//获取公司人员
export const getUserByCorporationKey = async function (params: { corporationKey: string }) {
  return await Http.get('/api/OverallAuthApi/GetUserByCorporationKey', params);
}

//获取菜单按钮权限
export const getMenuButtonAuthList = async function (params: { menuId: string, buttonRoleType: number,systemKey:string }) {
  return await Http.get('/api/OverallAuthApi/GetMenuButtonAuthList', params)
}

//获取菜单数据按钮权限
export const GetMenuDataButtonAuth = async function (params: any) {
  return await Http.post('/api/OverallAuthApi/GetMenuDataButtonAuth', params);
}

//获取菜单按钮权限
export const getMenuButtonList = async function (params: { menuId: string, buttonRoleType: number }) {
  return await Http.get('/api/OverallAuthApi/GetMenuButtonList', params)
}

//同步数据列字段
export const synchronousCols = async function () {
  return await Http.get('/api/OverallAuthApi/SynchronousCols');
}

//获取所有用户--创建用户缓存
export const getAllUserByCorporationKey = async function () {
  return await Http.get('/api/OverallAuthApi/GetAllUserByCorporationKey');
}

//获取所有部门--创建部门缓存
export const getAllDepartmentByCorporationKey = async function () {
  return await Http.get('/api/OverallAuthApi/GetAllDepartmentByCorporationKey');
}

//获取所有部门--创建部门树缓存
export const getDepartmentTree = async function () {
  return await Http.get('/api/OverallAuthApi/GetDepartmentTree');
}

//获取部门下的人员
export const GetDepartmentUser = async function () {
  return await Http.get('/api/OverallAuthApi/GetDepartmentUser');
}



/*以下接口要重新编写*/

//获取所有系统-select结构
export const getAllSystemSelect = async function (params?: { corporationKey?: string }) {
  return await Http.get('/api/SysSystem/GetAllByCorporationKey', params);
}

//获取树形结构角色数据
export const getRoleTree = async function (params?: { corporationKey?: string, systemKey?: string }) {
  return await Http.get('/api/SysRole/GetRoleTree', params);
}

//获取公司下部门
export const getCorporationDepartmentList = async function (params?: { corporationKey?: string }) {
  return await Http.get('/api/SysDepartment/GetCorporationDepartmentList', params);
}

//获取所有公司-select结构
export const getAllCorporationSelect = async function () {
  return await Http.get('/api/SysCorporation/GetAll');
}



